@extends('new.layouts.indexPublic')
@section('title'){{ Site::get('area_name').'职场资讯_'.Site::get('area_name').'人力资源政策劳动法苑-'.Site::get('webname') }} @endsection
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/new/css/index/news.css')}}">
@endsection
{{--主体内容--}}
@section('content')
    {{--主导航--}}
    @include('new.layouts.mainNav')
    {{--主导航结束--}}

    {{--主要内容--}}
    <div class="main">
        <div class="wrapper">
            {{--顶部左侧内容--}}
            <div class="topLeft">
                <ul>
                    @foreach($NewsImgExist as $k => $v)
                        @if($k == 0)
                            <li class="bigImg">
                                <a href="{{ route('newsinfo',['id'=>$v->imgWithNews->id]) }}" target="_blank">
                                    <img src={{ $v->imgUrl }} width="700" height="260">
                                    <div class="title"><span>{{ $v->imgWithNews->title }}</span></div>
                                </a>
                            </li>
                        @elseif($k < 3)
                            <li class="smallImg @if($k==2) noMarginRight @endif">
                                <a href="{{ route('newsinfo',['id'=>$v->imgWithNews->id]) }}" target="_blank">
                                    <img src="{{ $v->imgUrl }}" width="340" height="170">
                                    <div class="title"><span>{{ $v->imgWithNews->title }}</span></div>
                                </a>
                            </li>
                        @endif
                    @endforeach
                </ul>
            </div>
            {{--顶部右侧内容--}}
            {{--如果顶部左侧内容为空，则对顶部右侧调用noLeft样式--}}
            <div class="@if(count($NewsImgExist) != 0) topRight @else noLeft @endif">
                {{--搜索框--}}
                <form class="search" action="{{  route('news') }}" method="post" name="newsForm" id="newsForm">
                    {{csrf_field()}}
                    <input type="text" name="search" placeholder="请输入关键字" value="{{ old('search') }}"><button>搜索</button>
                </form>
                {{--热门文章--}}
                {{--如果顶部左侧、以及热门文章内容都为空，则对顶部右侧调用noLeft样式以及隐藏人们文章部分--}}
                <div class="hotArticles @if(count($NewsImgExist) == 0 && count($hotNews) == 0) hide @endif">
                    <h2><span>热门文章</span></h2>
                    <ul>
                        @if(count($hotNews) > 0 )
                            @foreach($hotNews as $k=>$v)
                                <li>
                                    @if($k < 3)
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="top">{{$k+1}}</span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @else
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            <span class="num">{{$k+1}}</span><span class="cont">{{ msubstr($v->title,0,23) }}</span>
                                        </a>
                                    @endif
                                </li>
                            @endforeach
                        @endif
                    </ul>
                </div>
            </div>
            {{--顶部右侧内容结束--}}

            {{--子导航--}}
            <ul class="subNav">
                <li><a class="active" href="{{url('/news')}}">最新动态<i class="smallAngle"></i></a></li>
                @if(count($secondClass) > 0 )
                    @foreach($secondClass as $k => $v)
                        <li><a href="{{ route('news') }}?class={{ $v->id }}">{{ $v->defectsname }}<i class="smallAngle"></i></a></li>
                    @endforeach
                @endif
            </ul>
            {{--子导航--}}

            {{--资讯列表--}}
            <div class="newLists">
                <ul>
                    @if(count($latelyNews) > 0)
                        @foreach($latelyNews as $v)
                            @if($v->imgUrl != '')
                                <li>
                                    <div class="left">
                                        <img src="{{ $v->imgUrl }}" alt="" width="215" height="140">
                                    </div>
                                    <div class="right hasLeft">
                                        <a class="title" href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            {{ str_limit($v->title,30) }}</a>
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            {{ $v->content }}</a>
                                        <div class="status">
                                            <span class="updateDate">{{ $v->updated_at }}</span>
                                            <span>阅读 {{ $v->readnum }}</span>
                                        </div>
                                    </div>
                                </li>
                            @else
                                <li>
                                    <div class="right">
                                        <a class="title" href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            {{ str_limit($v->title,30) }}</a>
                                        <a href="{{ route('newsinfo',['id'=>$v->id]) }}" target="_blank">
                                            {{ $v->content }}</a>
                                        <div class="status">
                                            <span class="updateDate">{{ $v->updated_at }}</span>
                                            <span>阅读 {{ $v->readnum }}</span>
                                        </div>
                                    </div>
                                </li>
                            @endif
                        @endforeach
                    @endif
                </ul>
                <div class="pageList">
                    @if(count($pageStr)>0)
                        {!! $latelyNews->appends($pageStr)->links() !!}
                    @else
                        {!! $latelyNews->links() !!}
                    @endif
                </div>
            </div>
            {{--资讯列表--}}
        </div>
    </div>
    {{--主要内容结束--}}
    <?php
    ?>
@endsection
{{--职位列表js--}}
@section('js')
    @parent
    <script>
        $(function(){
            //子导航高亮
            var classSearch = getQueryString("class");
            if(classSearch !=null && classSearch.toString().length>0){
                var $classification = $(".main .subNav li a"); //获取所有标签
                //根据地址栏参数值找到对应的标签设为高亮
                $classification.removeClass('active').eq(classSearch - 1).addClass('active');
            }
        });
        //获取地址栏某一参数的值
        function getQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null){
                return  decodeURI(r[2]); //对参数值进行解码操作
            }else{
                return null;
            }
        }
    </script>
@endsection